IOStream *err;
char *vmconfig;
int vmconfig_n;
- int (*suspend)(u32 domain, void *data);
+ int (*suspend)(void *data, u32 domain);
+ int (*configure)(void *data, u32 domain, char *vmconfig, int vmconfig_n);
void *data;
} XcIOContext;
int err = 0;
if(ctxt->suspend){
- err = ctxt->suspend(ctxt->domain, ctxt->data);
+ err = ctxt->suspend(ctxt->data, ctxt->domain);
+ } else {
+ err = -EINVAL;
+ }
+ return err;
+}
+
+static inline int xcio_configure_domain(XcIOContext *ctxt){
+ int err = 0;
+
+ if(ctxt->configure){
+ err = ctxt->configure(ctxt->data, ctxt->domain, ctxt->vmconfig, ctxt->vmconfig_n);
} else {
err = -EINVAL;
}
raise VmError('missing memory size')
self.init_domain()
+ self.construct_image()
self.configure_console()
self.configure_restart()
self.configure_backends()
deferred = self.configure()
- def cbok(val):
- return self.construct_image()
def cberr(err):
self.destroy()
return err
- deferred.addCallback(cbok)
deferred.addErrback(cberr)
except StandardError, ex:
# Catch errors, cleanup and re-raise.
devices have been released.
"""
if self.dom is None: return 0
- if self.console:
- if self.restart_pending():
- self.console.deregisterChannel()
- else:
- log.debug('Closing console, domain %s', self.id)
- self.console.close()
+ self.destroy_console()
chan = xend.getDomChannel(self.dom)
if chan:
log.debug("Closing channel to domain %d", self.dom)
except Exception, err:
log.exception("Domain destroy failed: %s", self.name)
+ def destroy_console(self):
+ if self.console:
+ if self.restart_pending():
+ self.console.deregisterChannel()
+ else:
+ log.debug('Closing console, domain %s', self.id)
+ self.console.close()
+
def cleanup(self):
"""Cleanup vm resources: release devices.
"""
#define MODULE_NAME "XFRD"
#define DEBUG 1
-#undef DEBUG
+//#undef DEBUG
#include "debug.h"
-
-int domain_suspend(u32 dom, void *data){
+int domain_suspend(void *data, u32 dom){
int err = 0;
Conn *xend = data;
return err;
}
+int domain_configure(void *data, u32 dom, char *vmconfig, int vmconfig_n){
+ return xen_domain_configure(dom, vmconfig, vmconfig_n);
+}
+
#ifndef _XEN_XFR_STUB_
static int xc_handle = 0;
ioctxt->io = io;
ioctxt->info = iostdout;
ioctxt->err = iostderr;
+ ioctxt->configure = domain_configure;
err = xc_linux_restore(xcinit(), ioctxt);
*dom = ioctxt->domain;
#include "select.h"
#define MODULE_NAME "XFRD"
-#define DEBUG 0
-#undef DEBUG
+#define DEBUG 1
+//#undef DEBUG
#include "debug.h"
/*
// before we configure the new one.
err = Conn_sxpr(peer, &sxpr);
if(err) goto exit;
- //sleep(2);
err = xen_domain_configure(state->vmid_new, state->vmconfig, state->vmconfig_n);
if(err) goto exit;
err = xen_domain_unpause(state->vmid_new);
pid_t pid;
int err = 0;
- dprintf(">\n");
+ dprintf("> sock=%d\n", sock);
dprintf("> accept...\n");
peersock = accept(sock, peer, &peer_n);
dprintf("> accept=%d\n", peersock);
err = -errno;
goto exit;
}
- iprintf("> Accepted connection from %s:%d\n",
- inet_ntoa(peer_in.sin_addr), htons(peer_in.sin_port));
+ iprintf("> Accepted connection from %s:%d on %d\n",
+ inet_ntoa(peer_in.sin_addr), htons(peer_in.sin_port), sock);
pid = fork();
if(pid > 0){
// Parent, fork succeeded.